home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / CABArchiver.java < prev    next >
Text File  |  1998-10-14  |  2KB  |  82 lines

  1. package com.symantec.itools.tools.archive;
  2.  
  3.  
  4. import java.io.File;
  5. import java.io.IOException;
  6. import com.symantec.itools.io.FileSystem;
  7. import com.symantec.itools.lang.Debug;
  8. import com.symantec.itools.lang.ProcessManager;
  9.  
  10.  
  11. /**
  12.  * @author Symantec Internet Tools Division
  13.  * @version 1.0
  14.  * @since VCafe 3.0
  15.  */
  16.  
  17. public class CABArchiver
  18.     extends TypeArchiver
  19. {
  20.     /**
  21.      * @since VCafe 3.0
  22.      */
  23.     protected ProcessManager processManager;
  24.  
  25.     public CABArchiver(Options options)
  26.     {
  27.         super(options);
  28.     }
  29.  
  30.     /**
  31.      * @param errorMsg TODO
  32.      * @since VCafe 3.0
  33.      */
  34.     public boolean create(StringBuffer errorMsg)
  35.     {
  36.         DirectoryArchiver archiver;
  37.         String            outFile;
  38.         StringBuffer      command;
  39.  
  40.         outFile = options.getOutputLocation();
  41.         options.setOutputLocation(options.getTempDir());
  42.         archiver = new DirectoryArchiver(options);
  43.  
  44.         if(!(archiver.create(errorMsg)))
  45.         {
  46.             return (false);
  47.         }
  48.  
  49.         options.setOutputLocation(outFile);
  50.         command = new StringBuffer(FileSystem.quoteIfNeeded(FileSystem.getCanonicalPath(options.getMicrosoftTools(), true) + "cabarc.exe"));
  51.         command.append(' ').append(options.getArchiverArgs());
  52.         
  53.         try
  54.         {
  55.             processManager = new ProcessManager();
  56.  
  57.             if(processManager.monitorLaunchedProcess(Runtime.getRuntime().exec(command.toString())) != 0)
  58.             {
  59.                 return (false);
  60.             }
  61.         }
  62.         catch(IOException ex)
  63.         {
  64.             Debug.logException(ex);
  65.             return (false);
  66.         }
  67.  
  68.         return (true);
  69.     }
  70.  
  71.     /**
  72.      * @since VCafe 3.0
  73.      */
  74.     public void cancel()
  75.     {
  76.         if(processManager != null)
  77.         {
  78.             processManager.destroyProcess();
  79.             processManager = null;
  80.         }
  81.     }
  82. }